<!--
 * @Descripttion: 
 * @version: 
 * @Author: lsy
 * @Date: 2021-12-15 13:31:02
 * @LastEditors: lsy
 * @LastEditTime: 2021-12-15 13:49:03
-->

<template>
    <div :id="qrcodeId"></div>
</template>
<script>
import QRCode from 'qrcodejs2'
export default {
    props: ["url", "qrcodeId"],
    mounted() {
        this.getCode()
    },
    methods: {
        getCode() {
            document.getElementById(`${this.qrcodeId}`).innerHTML = "";
            new QRCode(`${this.qrcodeId}`, {
                width: 150,
                height: 150, // 高度
                text: this.url// 二维码内容
                // render: 'canvas' // 设置渲染方式（有两种方式 table和canvas，默认是canvas）
                // background: '#f0f'
                // foreground: '#ff0'
            })
        }
    }
}
</script>